<template>
	<view>
		<view class="back-view" @touchmove.stop.prevent="moveHandle">
			<view class="view-background"></view>
			<view class="white-view-back">
				<view class="top-back">
					<view class="top-name">承办律师</view>
					<view class="close-back" @click="closeBtnAction">
						<image class="close-img" src="../../../static/close.png"></image>
					</view>
				</view>
				<view class="top-line"></view>

				<view class="content-back">
					<view class="item-back" v-for="(item,index) in lawyerList" :key="index" @click="clickLawyerAction(item)">
						<image class="header-img" :src="item.user.account.avatarPic"></image>
						<view class="header-name">{{item.user.account.realName}}</view>

					</view>
					<view class="item-back" @click="clickAddAction">
						<image class="header-img1" src="../../../static/phone/phone_add_people.png"></image>
						<view class="header-name header-name1">添加</view>

					</view>
					<view class="item-back" @click="clickDelAction">
						<image class="header-img1" src="../../../static/phone/phone_delete_people.png"></image>
						<view class="header-name header-name1">移除</view>

					</view>
				</view>
			</view>
		</view>
		<lawyerListAdd v-on:successBack='updataRequest()' v-if="showLawyerListAdd" :hasLawyers='lawyerList'
			:selectItemID="selectItemID" @lawyerAddClose='clickLawyerAddClose'></lawyerListAdd>
		<lawyerListDel v-on:successBack='updataRequest()' v-if="showLawyerListDel" :selectItemID="selectItemID"
			@clickLawListDelClose='clickLawListDelClose'></lawyerListDel>
		<lawyerInfo v-if="showLawyerInfo" :lawyerID="lawyerID" @clickLawInfoClose='clickLawInfoClose'>
		</lawyerInfo>
	</view>
</template>

<script>
	import lawyerListDel from "@/packageC/PhonePC/info/lawyerListDel.vue"
	import lawyerListAdd from "@/packageC/PhonePC/info/lawyerListAdd.vue"
	import lawyerInfo from "@/packageC/PhonePC/info/lawyerInfo.vue"
	let app = ''
	export default {
		components: {
			lawyerListDel,
			lawyerListAdd,
			lawyerInfo
		},
		props: {
			selectItemID: {
				type: String,
				default: ''
			},
		},
		data() {
			return {

				lawyerList: [],
				showLawyerListDel: false,
				showLawyerListAdd: false,
				showLawyerInfo: false,
				role: '', //当前登录角色
				roleUrl: '',
				lawyerID:''
			}
		},
		mounted() {
			var _this = this;
			app = getApp()
			_this.role = app.globalData.role
			_this.roleUrl = _this.$roleUrl({
				tab: _this.role
			})
			this.getCaseUserLawyers();
		},
		methods: {
			//刷新
			updataRequest() {
				this.getCaseUserLawyers();
				this.$emit("successBack");
			},

			/**
			 * 承办律师
			 */
			async getCaseUserLawyers() {
				let _this = this
				const res = await _this.$myRequest({
					url: `/${_this.roleUrl}/caseUser/lawyers`,
					data: {
						caseId: _this.selectItemID,
					}
				})
				// console.log('承办律师',res)
				if (res.data.code == 200) {
					let list = res.data.data

					for (var i = 0; i < list.length; i++) {
						let icons = list[i]['avatarPic']
						if (icons == undefined || icons == null || icons == '') {
							icons = _this.moren
						}
						list[i]['avatarPic'] = icons
					}
					if (list.lenth > 5) {
						for (var i = 0; i < 5; i++) {
							_this.lawyerList.push(list[i])
						}
					} else {
						_this.lawyerList = list
					}
				}
			},
			closeBtnAction() {
				console.log('222')
				this.$emit('clickLawListClose')
			},
			moveHandle() {
				return true
			},
			clickLawyerAddClose() {
				this.showLawyerListAdd = false;
			},
			clickAddAction() {
				this.showLawyerListAdd = true;
			},
			clickDelAction() {
				this.showLawyerListDel = true;
			},
			clickLawListDelClose() {
				this.showLawyerListDel = false;
			},
			clickLawyerAction(item) {
				this.lawyerID = item.accId;
				this.showLawyerInfo = true;
			},
			clickLawInfoClose(){
				this.showLawyerInfo = false;
			}
		},
	}
</script>

<style>
	.back-view {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 99;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.view-background {
		position: absolute;
		width: 100%;
		height: 100%;
		z-index: 100;
		background-color: rgba(0, 0, 0, 0.3);
	}

	.white-view-back {
		width: 556px;
		height: 500px;
		padding: 24px;
		max-height: 540px;
		background-color: white;
		margin-top: -50px;
		border-radius: 4px;
		z-index: 101;
		position: absolute;
	}

	.top-back {
		display: flex;
		justify-content: space-between;
	}

	.top-name {
		font-size: 18px;
		font-weight: normal;
		color: #333333;

	}

	.close-back {
		cursor: pointer;
		width: 20px;
		height: 20px;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.close-img {
		width: 12px;
		height: 12px;
	}

	.top-line {
		height: 1px;
		background: #EEEEEE;
		width: 100%;
		margin-top: 20px;
		margin-bottom: 20px;
	}

	.content-back {
		display: flex;
		flex-wrap: wrap;
	}

	.item-back {
		margin: 18px;
		display: flex;
		justify-content: center;

		align-items: center;
		flex-direction: column;
	}

	.header-img {
		height: 56px;
		width: 56px;
		border-radius: 50%;
		background-color: #EEEEEE;
	}

	.header-img1 {
		height: 56px;
		width: 56px;
		border-radius: 50%;
	}

	.header-name {
		font-size: 14px;
		font-weight: 600;
		color: #333333;
		margin-top: 6px;
	}

	.header-name1 {
		color: #999;
	}
</style>
